#delimit;
clear;
version 12.0;
pause on;
program drop _all;
set more off;
capture log close;

/*INSERT FOLDER PATH*/
cd /;




use retracted1129_analysisdata.dta, clear;

/**/
xtqmlp nbcites treat i.age i.yr, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_retracted1129.ster, replace;

xtqmlp nbcites treat i.age i.yr if rtrct_reason!=10, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_retracted1129_nonmissing.ster, replace;

xtqmlp nbcites treat treatXshky_shldrs treatXabsnt_shldrs i.age i.yr if rtrct_reason!=10, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_retracted1129_shldrs_nonmissing.ster, replace;

xtqmlp nbcites treat treatXabsnt_shldrs i.age i.yr if (shldrs==1|shldrs==2), fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_retracted1129_nostrng.ster, replace;

xtqmlp nbcites treat i.age i.yr if (earlst==1 & (shldrs==1|shldrs==2)), fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_retracted1129_nostrng_earlst.ster, replace;

xtqmlp nbcites treat treatXbigfraud i.age i.yr if subv_of_trth_strct==1, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_retracted1129_bigfraud_strct.ster, replace;


/**/
xtqmlp nbcites_ncorp treat i.age i.yr if corp_rlvnt_smpl==1 & shldrs==2, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
estimates save estimates/poisson_retracted1129_strct_ncorp.ster, replace;

xtqmlp nbcites_corp  treat i.age i.yr if corp_rlvnt_smpl==1 & shldrs==2, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
estimates save estimates/poisson_retracted1129_strct_corp.ster, replace;

xtqmlp nbcites_ncorp treat treatXcited_in_patent i.age i.yr if corp_rlvnt_smpl==1 & shldrs==2, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
estimates save estimates/poisson_retracted1129_strct_patentcites_ncorp.ster, replace;

xtqmlp nbcites_corp  treat treatXcited_in_patent i.age i.yr if corp_rlvnt_smpl==1 & shldrs==2, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
estimates save estimates/poisson_retracted1129_strct_patentcites_corp.ster, replace;



/*tables*/
set emptycells drop;
set matsize 1000;
estimates drop _all;

estimates use  estimates/poisson_retracted1129.ster;
eststo;
estimates use  estimates/poisson_retracted1129_nonmissing.ster;
eststo;
estimates use  estimates/poisson_retracted1129_shldrs_nonmissing.ster;
eststo;
estimates use  estimates/poisson_retracted1129_nostrng.ster;
eststo;
estimates use  estimates/poisson_retracted1129_nostrng_earlst.ster;
eststo;


esttab *, keep(treat treatXshky_shldrs treatXabsnt_shldrs ) varwidth(25) nonumber noobs nogaps nodep label b(%5.3f) se(%5.3f) star(� 0.10 * 0.05 ** 0.01) compress scalars("nbcases Nb. of Retraction Cases" "N_g Nb. of Retracted/Control Articles" "N Nb. of Article-Year Obs." "ll Log Likelihood") sfmt(%10.0fc %10.0fc %10.0fc %10.0fc) mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)") eqlabels(none);
esttab * using tables/table_poisson_retracted1129_reasons.rtf, keep(treat treatXshky_shldrs treatXabsnt_shldrs ) varwidth(25) nonumber noobs nogaps nodep label b(%5.3f) se(%5.3f) star(� 0.10 * 0.05 ** 0.01) compress scalars("nbcases Nb. of Retraction Cases" "N_g Nb. of Retracted/Control Articles" "N Nb. of Article-Year Obs." "ll Log Likelihood") sfmt(%10.0fc %10.0fc %10.0fc %10.0fc) mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)") eqlabels(none) replace;


set emptycells drop;
	set matsize 1000;
	estimates drop _all;
	
	estimates use  estimates/poisson_retracted1129_strct_ncorp.ster;
	eststo;
	estimates use  estimates/poisson_retracted1129_strct_corp.ster;
	eststo;
	estimates use  estimates/poisson_retracted1129_strct_patentcites_ncorp.ster;
	eststo;
	estimates use  estimates/poisson_retracted1129_strct_patentcites_corp.ster;
	eststo;	
	
	
	esttab *, keep(treat treatXcited_in_patent) varwidth(25) nonumber noobs nogaps nodep label b(%5.3f) se(%5.3f) star(� 0.10 * 0.05 ** 0.01) compress scalars("nbcases Nb. of Retraction Cases" "nbsource Nb. of Source Articles" "N_g Nb. of Related/Control Articles" "N Nb. of Article-Year Obs." "ll Log Likelihood") sfmt(%10.0fc %10.0fc %10.0fc %10.0fc) mlabels("(1a) Academic Citations Only" "(1b) Private-Firms Citations Only" "(1c) Academic Citations Only" "(1d) Private-Firms Citations Only") eqlabels(none);
	
	esttab * using tables/table_poisson_retracted1129_corpncorp_patentcites.rtf, keep(treat treatXcited_in_patent ) varwidth(25) nonumber noobs nogaps nodep label b(%5.3f) se(%5.3f) star(� 0.10 * 0.05 ** 0.01) compress scalars("nbcases Nb. of Retraction Cases" "nbsource Nb. of Source Articles" "N_g Nb. of Related/Control Articles" "N Nb. of Article-Year Obs." "ll Log Likelihood")sfmt(%10.0fc %10.0fc %10.0fc %10.0fc) mlabels("(1a) Academic Citations Only" "(1b) Private-Firms Citations Only" "(1c) Academic Citations Only" "(1d) Private-Firms Citations Only") eqlabels(none) replace;
	
	



exit;